package com.example.myproject.client;

import java.util.ArrayList;
import java.util.List;
import java.util.Iterator;

import com.example.myproject.shared.FieldVerifier;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.DecoratedTabBar;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.IntegerBox;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.TextBoxBase;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.i18n.client.Dictionary;
import com.google.gwt.json.client.JSONNumber;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.storage.client.*;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Habitat_Configuration_System implements EntryPoint {

	List<Module> allModules = new ArrayList<Module>();
	List<Module> airLockList = new ArrayList<Module>();
	List<Module> canteenList = new ArrayList<Module>();
	List<Module> controlList = new ArrayList<Module>();
	List<Module> dormitoryList = new ArrayList<Module>();
	List<Module> foodList = new ArrayList<Module>();
	List<Module> gymList = new ArrayList<Module>();
	List<Module> medicalList = new ArrayList<Module>();
	List<Module> plainList = new ArrayList<Module>();
	List<Module> powerList = new ArrayList<Module>();
	List<Module> sanitationList = new ArrayList<Module>();
	
	List<List<Module>> listOfConfigurationList = new ArrayList<List<Module>>();
	
	List<Module> config1 = new ArrayList<Module>();
	List<Module> config2 = new ArrayList<Module>();
	List<Module> config3 = new ArrayList<Module>();
	boolean tab1Selected = false;
	boolean tab2Selected = false;
	boolean tab3Selected = false;
	Grid grid_2 = new Grid(50, 100);
	Module selMod;
	Button btnAddModule = new Button("New button");
	Button btnUpdateModule = new Button("Update Module");
	Button btnDeleteModule = new Button("Delete Module");
	final ListBox typeDrop = new ListBox();
	final ListBox condDrop = new ListBox();
	final IntegerBox numBox = new IntegerBox();
	final ListBox turnBox = new ListBox();
	final IntegerBox longBox = new IntegerBox();
	final IntegerBox latBox = new IntegerBox();
	
	
	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {

		// Add the nameField and sendButton to the RootPanel
		// Use RootPanel.get() to get the entire body element
		RootPanel rootPanel = RootPanel.get();
		rootPanel.setSize("1024", "768");
		
		VerticalPanel verticalPanel = new VerticalPanel();
		rootPanel.add(verticalPanel, 0, 0);
		verticalPanel.setSize("638px", "780px");
		
		MenuBar menuBar = new MenuBar(false);
		verticalPanel.add(menuBar);
		MenuBar menuBar_2 = new MenuBar(true);
		
		MenuItem mntmFile = new MenuItem("File", false, menuBar_2);
		
		MenuItem mntmSave = new MenuItem("Save", false, new Command() {
			public void execute() {
				saveToLocalStorage();
			}
		});
		menuBar_2.addItem(mntmSave);
		
		MenuItem mntmLoad = new MenuItem("Load", false, new Command() {
			public void execute() {
				loadFromStorage();
			}
		});
		menuBar_2.addItem(mntmLoad);
		menuBar.addItem(mntmFile);
		MenuBar menuBar_1 = new MenuBar(true);
		
		MenuItem mntmGps_1 = new MenuItem("GPS", false, menuBar_1);
		
		MenuItem mntmUpdateFromGps = new MenuItem("Update from GPS", false, new Command() {
			public void execute() {
				Dictionary m1 = Dictionary.getDictionary("module1");
				if(Integer.parseInt(m1.get("code")) >= 1 && Integer.parseInt(m1.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m1.get("code")), Integer.parseInt(m1.get("X")), Integer.parseInt(m1.get("Y")), m1.get("turns"), "Plain", m1.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m1.get("code")) >= 61 && Integer.parseInt(m1.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m1.get("code")), Integer.parseInt(m1.get("X")), Integer.parseInt(m1.get("Y")), m1.get("turns"), "Dormitory", m1.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m1.get("code")) >= 91 && Integer.parseInt(m1.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m1.get("code")), Integer.parseInt(m1.get("X")), Integer.parseInt(m1.get("Y")), m1.get("turns"), "Sanitation", m1.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m1.get("code")) >= 111 && Integer.parseInt(m1.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m1.get("code")), Integer.parseInt(m1.get("X")), Integer.parseInt(m1.get("Y")), m1.get("turns"), "Food & Water", m1.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m1.get("code")) >= 131 && Integer.parseInt(m1.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m1.get("code")), Integer.parseInt(m1.get("X")), Integer.parseInt(m1.get("Y")), m1.get("turns"), "Gym & Relaxation", m1.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m1.get("code")) >= 141 && Integer.parseInt(m1.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m1.get("code")), Integer.parseInt(m1.get("X")), Integer.parseInt(m1.get("Y")), m1.get("turns"), "Canteen", m1.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m1.get("code")) >= 151 && Integer.parseInt(m1.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m1.get("code")), Integer.parseInt(m1.get("X")), Integer.parseInt(m1.get("Y")), m1.get("turns"), "Power", m1.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m1.get("code")) >= 161 && Integer.parseInt(m1.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m1.get("code")), Integer.parseInt(m1.get("X")), Integer.parseInt(m1.get("Y")), m1.get("turns"), "Control", m1.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m1.get("code")) >= 171 && Integer.parseInt(m1.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m1.get("code")), Integer.parseInt(m1.get("X")), Integer.parseInt(m1.get("Y")), m1.get("turns"), "Airlock", m1.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m1.get("code")) >= 181 && Integer.parseInt(m1.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m1.get("code")), Integer.parseInt(m1.get("X")), Integer.parseInt(m1.get("Y")), m1.get("turns"), "Medical", m1.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}
				
				Dictionary m2 = Dictionary.getDictionary("module2");
				if(Integer.parseInt(m2.get("code")) >= 1 && Integer.parseInt(m2.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m2.get("code")), Integer.parseInt(m2.get("X")), Integer.parseInt(m2.get("Y")), m2.get("turns"), "Plain", m2.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m2.get("code")) >= 61 && Integer.parseInt(m2.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m2.get("code")), Integer.parseInt(m2.get("X")), Integer.parseInt(m2.get("Y")), m2.get("turns"), "Dormitory", m2.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m2.get("code")) >= 91 && Integer.parseInt(m2.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m2.get("code")), Integer.parseInt(m2.get("X")), Integer.parseInt(m2.get("Y")), m2.get("turns"), "Sanitation", m2.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m2.get("code")) >= 111 && Integer.parseInt(m2.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m2.get("code")), Integer.parseInt(m2.get("X")), Integer.parseInt(m2.get("Y")), m2.get("turns"), "Food & Water", m2.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m2.get("code")) >= 131 && Integer.parseInt(m2.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m2.get("code")), Integer.parseInt(m2.get("X")), Integer.parseInt(m2.get("Y")), m2.get("turns"), "Gym & Relaxation", m2.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m2.get("code")) >= 141 && Integer.parseInt(m2.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m2.get("code")), Integer.parseInt(m2.get("X")), Integer.parseInt(m2.get("Y")), m2.get("turns"), "Canteen", m2.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m2.get("code")) >= 151 && Integer.parseInt(m2.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m2.get("code")), Integer.parseInt(m2.get("X")), Integer.parseInt(m2.get("Y")), m2.get("turns"), "Power", m2.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m2.get("code")) >= 161 && Integer.parseInt(m2.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m2.get("code")), Integer.parseInt(m2.get("X")), Integer.parseInt(m2.get("Y")), m2.get("turns"), "Control", m2.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m2.get("code")) >= 171 && Integer.parseInt(m2.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m2.get("code")), Integer.parseInt(m2.get("X")), Integer.parseInt(m2.get("Y")), m2.get("turns"), "Airlock", m2.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m2.get("code")) >= 181 && Integer.parseInt(m2.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m2.get("code")), Integer.parseInt(m2.get("X")), Integer.parseInt(m2.get("Y")), m2.get("turns"), "Medical", m2.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}
				
				Dictionary m3 = Dictionary.getDictionary("module3");
				if(Integer.parseInt(m3.get("code")) >= 1 && Integer.parseInt(m3.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m3.get("code")), Integer.parseInt(m3.get("X")), Integer.parseInt(m3.get("Y")), m3.get("turns"), "Plain", m3.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m3.get("code")) >= 61 && Integer.parseInt(m3.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m3.get("code")), Integer.parseInt(m3.get("X")), Integer.parseInt(m3.get("Y")), m3.get("turns"), "Dormitory", m3.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m3.get("code")) >= 91 && Integer.parseInt(m3.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m3.get("code")), Integer.parseInt(m3.get("X")), Integer.parseInt(m3.get("Y")), m3.get("turns"), "Sanitation", m3.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m3.get("code")) >= 111 && Integer.parseInt(m3.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m3.get("code")), Integer.parseInt(m3.get("X")), Integer.parseInt(m3.get("Y")), m3.get("turns"), "Food & Water", m3.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m3.get("code")) >= 131 && Integer.parseInt(m3.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m3.get("code")), Integer.parseInt(m3.get("X")), Integer.parseInt(m3.get("Y")), m3.get("turns"), "Gym & Relaxation", m3.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m3.get("code")) >= 141 && Integer.parseInt(m3.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m3.get("code")), Integer.parseInt(m3.get("X")), Integer.parseInt(m3.get("Y")), m3.get("turns"), "Canteen", m3.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m3.get("code")) >= 151 && Integer.parseInt(m3.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m3.get("code")), Integer.parseInt(m3.get("X")), Integer.parseInt(m3.get("Y")), m3.get("turns"), "Power", m3.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m3.get("code")) >= 161 && Integer.parseInt(m3.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m3.get("code")), Integer.parseInt(m3.get("X")), Integer.parseInt(m3.get("Y")), m3.get("turns"), "Control", m3.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m3.get("code")) >= 171 && Integer.parseInt(m3.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m3.get("code")), Integer.parseInt(m3.get("X")), Integer.parseInt(m3.get("Y")), m3.get("turns"), "Airlock", m3.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m3.get("code")) >= 181 && Integer.parseInt(m3.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m3.get("code")), Integer.parseInt(m3.get("X")), Integer.parseInt(m3.get("Y")), m3.get("turns"), "Medical", m3.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}

				Dictionary m4 = Dictionary.getDictionary("module4");
				if(Integer.parseInt(m4.get("code")) >= 1 && Integer.parseInt(m4.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m4.get("code")), Integer.parseInt(m4.get("X")), Integer.parseInt(m4.get("Y")), m4.get("turns"), "Plain", m4.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m4.get("code")) >= 61 && Integer.parseInt(m4.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m4.get("code")), Integer.parseInt(m4.get("X")), Integer.parseInt(m4.get("Y")), m4.get("turns"), "Dormitory", m4.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m4.get("code")) >= 91 && Integer.parseInt(m4.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m4.get("code")), Integer.parseInt(m4.get("X")), Integer.parseInt(m4.get("Y")), m4.get("turns"), "Sanitation", m4.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m4.get("code")) >= 111 && Integer.parseInt(m4.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m4.get("code")), Integer.parseInt(m4.get("X")), Integer.parseInt(m4.get("Y")), m4.get("turns"), "Food & Water", m4.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m4.get("code")) >= 131 && Integer.parseInt(m4.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m4.get("code")), Integer.parseInt(m4.get("X")), Integer.parseInt(m4.get("Y")), m4.get("turns"), "Gym & Relaxation", m4.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m4.get("code")) >= 141 && Integer.parseInt(m4.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m4.get("code")), Integer.parseInt(m4.get("X")), Integer.parseInt(m4.get("Y")), m4.get("turns"), "Canteen", m4.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m4.get("code")) >= 151 && Integer.parseInt(m4.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m4.get("code")), Integer.parseInt(m4.get("X")), Integer.parseInt(m4.get("Y")), m4.get("turns"), "Power", m4.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m4.get("code")) >= 161 && Integer.parseInt(m4.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m4.get("code")), Integer.parseInt(m4.get("X")), Integer.parseInt(m4.get("Y")), m4.get("turns"), "Control", m4.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m4.get("code")) >= 171 && Integer.parseInt(m4.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m4.get("code")), Integer.parseInt(m4.get("X")), Integer.parseInt(m4.get("Y")), m4.get("turns"), "Airlock", m4.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m4.get("code")) >= 181 && Integer.parseInt(m4.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m4.get("code")), Integer.parseInt(m4.get("X")), Integer.parseInt(m4.get("Y")), m4.get("turns"), "Medical", m4.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}

				Dictionary m5 = Dictionary.getDictionary("module5");
				if(Integer.parseInt(m5.get("code")) >= 1 && Integer.parseInt(m5.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m5.get("code")), Integer.parseInt(m5.get("X")), Integer.parseInt(m5.get("Y")), m5.get("turns"), "Plain", m5.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m5.get("code")) >= 61 && Integer.parseInt(m5.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m5.get("code")), Integer.parseInt(m5.get("X")), Integer.parseInt(m5.get("Y")), m5.get("turns"), "Dormitory", m5.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m5.get("code")) >= 91 && Integer.parseInt(m5.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m5.get("code")), Integer.parseInt(m5.get("X")), Integer.parseInt(m5.get("Y")), m5.get("turns"), "Sanitation", m5.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m5.get("code")) >= 111 && Integer.parseInt(m5.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m5.get("code")), Integer.parseInt(m5.get("X")), Integer.parseInt(m5.get("Y")), m5.get("turns"), "Food & Water", m5.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m5.get("code")) >= 131 && Integer.parseInt(m5.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m5.get("code")), Integer.parseInt(m5.get("X")), Integer.parseInt(m5.get("Y")), m5.get("turns"), "Gym & Relaxation", m5.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m5.get("code")) >= 141 && Integer.parseInt(m5.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m5.get("code")), Integer.parseInt(m5.get("X")), Integer.parseInt(m5.get("Y")), m5.get("turns"), "Canteen", m5.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m5.get("code")) >= 151 && Integer.parseInt(m5.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m5.get("code")), Integer.parseInt(m5.get("X")), Integer.parseInt(m5.get("Y")), m5.get("turns"), "Power", m5.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m5.get("code")) >= 161 && Integer.parseInt(m5.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m5.get("code")), Integer.parseInt(m5.get("X")), Integer.parseInt(m5.get("Y")), m5.get("turns"), "Control", m5.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m5.get("code")) >= 171 && Integer.parseInt(m5.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m5.get("code")), Integer.parseInt(m5.get("X")), Integer.parseInt(m5.get("Y")), m5.get("turns"), "Airlock", m5.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m5.get("code")) >= 181 && Integer.parseInt(m5.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m5.get("code")), Integer.parseInt(m5.get("X")), Integer.parseInt(m5.get("Y")), m5.get("turns"), "Medical", m5.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}

				Dictionary m6 = Dictionary.getDictionary("module6");
				if(Integer.parseInt(m6.get("code")) >= 1 && Integer.parseInt(m6.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m6.get("code")), Integer.parseInt(m6.get("X")), Integer.parseInt(m6.get("Y")), m6.get("turns"), "Plain", m6.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m6.get("code")) >= 61 && Integer.parseInt(m6.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m6.get("code")), Integer.parseInt(m6.get("X")), Integer.parseInt(m6.get("Y")), m6.get("turns"), "Dormitory", m6.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m6.get("code")) >= 91 && Integer.parseInt(m6.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m6.get("code")), Integer.parseInt(m6.get("X")), Integer.parseInt(m6.get("Y")), m6.get("turns"), "Sanitation", m6.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m6.get("code")) >= 111 && Integer.parseInt(m6.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m6.get("code")), Integer.parseInt(m6.get("X")), Integer.parseInt(m6.get("Y")), m6.get("turns"), "Food & Water", m6.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m6.get("code")) >= 131 && Integer.parseInt(m6.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m6.get("code")), Integer.parseInt(m6.get("X")), Integer.parseInt(m6.get("Y")), m6.get("turns"), "Gym & Relaxation", m6.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m6.get("code")) >= 141 && Integer.parseInt(m6.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m6.get("code")), Integer.parseInt(m6.get("X")), Integer.parseInt(m6.get("Y")), m6.get("turns"), "Canteen", m6.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m6.get("code")) >= 151 && Integer.parseInt(m6.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m6.get("code")), Integer.parseInt(m6.get("X")), Integer.parseInt(m6.get("Y")), m6.get("turns"), "Power", m6.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m6.get("code")) >= 161 && Integer.parseInt(m6.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m6.get("code")), Integer.parseInt(m6.get("X")), Integer.parseInt(m6.get("Y")), m6.get("turns"), "Control", m6.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m6.get("code")) >= 171 && Integer.parseInt(m6.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m6.get("code")), Integer.parseInt(m6.get("X")), Integer.parseInt(m6.get("Y")), m6.get("turns"), "Airlock", m6.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m6.get("code")) >= 181 && Integer.parseInt(m6.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m6.get("code")), Integer.parseInt(m6.get("X")), Integer.parseInt(m6.get("Y")), m6.get("turns"), "Medical", m6.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}
				
				Dictionary m7 = Dictionary.getDictionary("module7");
				if(Integer.parseInt(m7.get("code")) >= 1 && Integer.parseInt(m7.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m7.get("code")), Integer.parseInt(m7.get("X")), Integer.parseInt(m7.get("Y")), m7.get("turns"), "Plain", m7.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m7.get("code")) >= 61 && Integer.parseInt(m7.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m7.get("code")), Integer.parseInt(m7.get("X")), Integer.parseInt(m7.get("Y")), m7.get("turns"), "Dormitory", m7.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m7.get("code")) >= 91 && Integer.parseInt(m7.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m7.get("code")), Integer.parseInt(m7.get("X")), Integer.parseInt(m7.get("Y")), m7.get("turns"), "Sanitation", m7.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m7.get("code")) >= 111 && Integer.parseInt(m7.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m7.get("code")), Integer.parseInt(m7.get("X")), Integer.parseInt(m7.get("Y")), m7.get("turns"), "Food & Water", m7.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m7.get("code")) >= 131 && Integer.parseInt(m7.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m7.get("code")), Integer.parseInt(m7.get("X")), Integer.parseInt(m7.get("Y")), m7.get("turns"), "Gym & Relaxation", m7.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m7.get("code")) >= 141 && Integer.parseInt(m7.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m7.get("code")), Integer.parseInt(m7.get("X")), Integer.parseInt(m7.get("Y")), m7.get("turns"), "Canteen", m7.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m7.get("code")) >= 151 && Integer.parseInt(m7.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m7.get("code")), Integer.parseInt(m7.get("X")), Integer.parseInt(m7.get("Y")), m7.get("turns"), "Power", m7.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m7.get("code")) >= 161 && Integer.parseInt(m7.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m7.get("code")), Integer.parseInt(m7.get("X")), Integer.parseInt(m7.get("Y")), m7.get("turns"), "Control", m7.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m7.get("code")) >= 171 && Integer.parseInt(m7.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m7.get("code")), Integer.parseInt(m7.get("X")), Integer.parseInt(m7.get("Y")), m7.get("turns"), "Airlock", m7.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m7.get("code")) >= 181 && Integer.parseInt(m7.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m7.get("code")), Integer.parseInt(m7.get("X")), Integer.parseInt(m7.get("Y")), m7.get("turns"), "Medical", m7.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}

				Dictionary m8 = Dictionary.getDictionary("module8");
				if(Integer.parseInt(m8.get("code")) >= 1 && Integer.parseInt(m8.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m8.get("code")), Integer.parseInt(m8.get("X")), Integer.parseInt(m8.get("Y")), m8.get("turns"), "Plain", m8.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m8.get("code")) >= 61 && Integer.parseInt(m8.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m8.get("code")), Integer.parseInt(m8.get("X")), Integer.parseInt(m8.get("Y")), m8.get("turns"), "Dormitory", m8.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m8.get("code")) >= 91 && Integer.parseInt(m8.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m8.get("code")), Integer.parseInt(m8.get("X")), Integer.parseInt(m8.get("Y")), m8.get("turns"), "Sanitation", m8.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m8.get("code")) >= 111 && Integer.parseInt(m8.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m8.get("code")), Integer.parseInt(m8.get("X")), Integer.parseInt(m8.get("Y")), m8.get("turns"), "Food & Water", m8.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m8.get("code")) >= 131 && Integer.parseInt(m8.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m8.get("code")), Integer.parseInt(m8.get("X")), Integer.parseInt(m8.get("Y")), m8.get("turns"), "Gym & Relaxation", m8.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m8.get("code")) >= 141 && Integer.parseInt(m8.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m8.get("code")), Integer.parseInt(m8.get("X")), Integer.parseInt(m8.get("Y")), m8.get("turns"), "Canteen", m8.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m8.get("code")) >= 151 && Integer.parseInt(m8.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m8.get("code")), Integer.parseInt(m8.get("X")), Integer.parseInt(m8.get("Y")), m8.get("turns"), "Power", m8.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m8.get("code")) >= 161 && Integer.parseInt(m8.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m8.get("code")), Integer.parseInt(m8.get("X")), Integer.parseInt(m8.get("Y")), m8.get("turns"), "Control", m8.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m8.get("code")) >= 171 && Integer.parseInt(m8.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m8.get("code")), Integer.parseInt(m8.get("X")), Integer.parseInt(m8.get("Y")), m8.get("turns"), "Airlock", m8.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m8.get("code")) >= 181 && Integer.parseInt(m8.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m8.get("code")), Integer.parseInt(m8.get("X")), Integer.parseInt(m8.get("Y")), m8.get("turns"), "Medical", m8.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}

				Dictionary m9 = Dictionary.getDictionary("module9");
				if(Integer.parseInt(m9.get("code")) >= 1 && Integer.parseInt(m9.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m9.get("code")), Integer.parseInt(m9.get("X")), Integer.parseInt(m9.get("Y")), m9.get("turns"), "Plain", m9.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m9.get("code")) >= 61 && Integer.parseInt(m9.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m9.get("code")), Integer.parseInt(m9.get("X")), Integer.parseInt(m9.get("Y")), m9.get("turns"), "Dormitory", m9.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m9.get("code")) >= 91 && Integer.parseInt(m9.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m9.get("code")), Integer.parseInt(m9.get("X")), Integer.parseInt(m9.get("Y")), m9.get("turns"), "Sanitation", m9.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m9.get("code")) >= 111 && Integer.parseInt(m9.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m9.get("code")), Integer.parseInt(m9.get("X")), Integer.parseInt(m9.get("Y")), m9.get("turns"), "Food & Water", m9.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m9.get("code")) >= 131 && Integer.parseInt(m9.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m9.get("code")), Integer.parseInt(m9.get("X")), Integer.parseInt(m9.get("Y")), m9.get("turns"), "Gym & Relaxation", m9.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m9.get("code")) >= 141 && Integer.parseInt(m9.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m9.get("code")), Integer.parseInt(m9.get("X")), Integer.parseInt(m9.get("Y")), m9.get("turns"), "Canteen", m9.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m9.get("code")) >= 151 && Integer.parseInt(m9.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m9.get("code")), Integer.parseInt(m9.get("X")), Integer.parseInt(m9.get("Y")), m9.get("turns"), "Power", m9.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m9.get("code")) >= 161 && Integer.parseInt(m9.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m9.get("code")), Integer.parseInt(m9.get("X")), Integer.parseInt(m9.get("Y")), m9.get("turns"), "Control", m9.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m9.get("code")) >= 171 && Integer.parseInt(m9.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m9.get("code")), Integer.parseInt(m9.get("X")), Integer.parseInt(m9.get("Y")), m9.get("turns"), "Airlock", m9.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m9.get("code")) >= 181 && Integer.parseInt(m9.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m9.get("code")), Integer.parseInt(m9.get("X")), Integer.parseInt(m9.get("Y")), m9.get("turns"), "Medical", m9.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}

				Dictionary m10 = Dictionary.getDictionary("module10");
				if(Integer.parseInt(m10.get("code")) >= 1 && Integer.parseInt(m10.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m10.get("code")), Integer.parseInt(m10.get("X")), Integer.parseInt(m10.get("Y")), m10.get("turns"), "Plain", m10.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m10.get("code")) >= 61 && Integer.parseInt(m10.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m10.get("code")), Integer.parseInt(m10.get("X")), Integer.parseInt(m10.get("Y")), m10.get("turns"), "Dormitory", m10.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m10.get("code")) >= 91 && Integer.parseInt(m10.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m10.get("code")), Integer.parseInt(m10.get("X")), Integer.parseInt(m10.get("Y")), m10.get("turns"), "Sanitation", m10.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m10.get("code")) >= 111 && Integer.parseInt(m10.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m10.get("code")), Integer.parseInt(m10.get("X")), Integer.parseInt(m10.get("Y")), m10.get("turns"), "Food & Water", m10.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m10.get("code")) >= 131 && Integer.parseInt(m10.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m10.get("code")), Integer.parseInt(m10.get("X")), Integer.parseInt(m10.get("Y")), m10.get("turns"), "Gym & Relaxation", m10.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m10.get("code")) >= 141 && Integer.parseInt(m10.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m10.get("code")), Integer.parseInt(m10.get("X")), Integer.parseInt(m10.get("Y")), m10.get("turns"), "Canteen", m10.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m10.get("code")) >= 151 && Integer.parseInt(m10.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m10.get("code")), Integer.parseInt(m10.get("X")), Integer.parseInt(m10.get("Y")), m10.get("turns"), "Power", m10.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m10.get("code")) >= 161 && Integer.parseInt(m10.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m10.get("code")), Integer.parseInt(m10.get("X")), Integer.parseInt(m10.get("Y")), m10.get("turns"), "Control", m10.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m10.get("code")) >= 171 && Integer.parseInt(m10.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m10.get("code")), Integer.parseInt(m10.get("X")), Integer.parseInt(m10.get("Y")), m10.get("turns"), "Airlock", m10.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m10.get("code")) >= 181 && Integer.parseInt(m10.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m10.get("code")), Integer.parseInt(m10.get("X")), Integer.parseInt(m10.get("Y")), m10.get("turns"), "Medical", m10.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}
				
				Dictionary m11 = Dictionary.getDictionary("module11");
				if(Integer.parseInt(m11.get("code")) >= 1 && Integer.parseInt(m11.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m11.get("code")), Integer.parseInt(m11.get("X")), Integer.parseInt(m11.get("Y")), m11.get("turns"), "Plain", m11.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m11.get("code")) >= 61 && Integer.parseInt(m11.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m11.get("code")), Integer.parseInt(m11.get("X")), Integer.parseInt(m11.get("Y")), m11.get("turns"), "Dormitory", m11.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m11.get("code")) >= 91 && Integer.parseInt(m11.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m11.get("code")), Integer.parseInt(m11.get("X")), Integer.parseInt(m11.get("Y")), m11.get("turns"), "Sanitation", m11.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m11.get("code")) >= 111 && Integer.parseInt(m11.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m11.get("code")), Integer.parseInt(m11.get("X")), Integer.parseInt(m11.get("Y")), m11.get("turns"), "Food & Water", m11.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m11.get("code")) >= 131 && Integer.parseInt(m11.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m11.get("code")), Integer.parseInt(m11.get("X")), Integer.parseInt(m11.get("Y")), m11.get("turns"), "Gym & Relaxation", m11.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m11.get("code")) >= 141 && Integer.parseInt(m11.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m11.get("code")), Integer.parseInt(m11.get("X")), Integer.parseInt(m11.get("Y")), m11.get("turns"), "Canteen", m11.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m11.get("code")) >= 151 && Integer.parseInt(m11.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m11.get("code")), Integer.parseInt(m11.get("X")), Integer.parseInt(m11.get("Y")), m11.get("turns"), "Power", m11.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m11.get("code")) >= 161 && Integer.parseInt(m11.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m11.get("code")), Integer.parseInt(m11.get("X")), Integer.parseInt(m11.get("Y")), m11.get("turns"), "Control", m11.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m11.get("code")) >= 171 && Integer.parseInt(m11.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m11.get("code")), Integer.parseInt(m11.get("X")), Integer.parseInt(m11.get("Y")), m11.get("turns"), "Airlock", m11.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m11.get("code")) >= 181 && Integer.parseInt(m11.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m11.get("code")), Integer.parseInt(m11.get("X")), Integer.parseInt(m11.get("Y")), m11.get("turns"), "Medical", m11.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}

				Dictionary m12 = Dictionary.getDictionary("module12");
				if(Integer.parseInt(m12.get("code")) >= 1 && Integer.parseInt(m12.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m12.get("code")), Integer.parseInt(m12.get("X")), Integer.parseInt(m12.get("Y")), m12.get("turns"), "Plain", m12.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m12.get("code")) >= 61 && Integer.parseInt(m12.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m12.get("code")), Integer.parseInt(m12.get("X")), Integer.parseInt(m12.get("Y")), m12.get("turns"), "Dormitory", m12.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m12.get("code")) >= 91 && Integer.parseInt(m12.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m12.get("code")), Integer.parseInt(m12.get("X")), Integer.parseInt(m12.get("Y")), m12.get("turns"), "Sanitation", m12.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m12.get("code")) >= 111 && Integer.parseInt(m12.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m12.get("code")), Integer.parseInt(m12.get("X")), Integer.parseInt(m12.get("Y")), m12.get("turns"), "Food & Water", m12.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m12.get("code")) >= 131 && Integer.parseInt(m12.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m12.get("code")), Integer.parseInt(m12.get("X")), Integer.parseInt(m12.get("Y")), m12.get("turns"), "Gym & Relaxation", m12.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m12.get("code")) >= 141 && Integer.parseInt(m12.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m12.get("code")), Integer.parseInt(m12.get("X")), Integer.parseInt(m12.get("Y")), m12.get("turns"), "Canteen", m12.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m12.get("code")) >= 151 && Integer.parseInt(m12.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m12.get("code")), Integer.parseInt(m12.get("X")), Integer.parseInt(m12.get("Y")), m12.get("turns"), "Power", m12.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m12.get("code")) >= 161 && Integer.parseInt(m12.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m12.get("code")), Integer.parseInt(m12.get("X")), Integer.parseInt(m12.get("Y")), m12.get("turns"), "Control", m12.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m12.get("code")) >= 171 && Integer.parseInt(m12.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m12.get("code")), Integer.parseInt(m12.get("X")), Integer.parseInt(m12.get("Y")), m12.get("turns"), "Airlock", m12.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m12.get("code")) >= 181 && Integer.parseInt(m12.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m12.get("code")), Integer.parseInt(m12.get("X")), Integer.parseInt(m12.get("Y")), m12.get("turns"), "Medical", m12.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}

				Dictionary m13 = Dictionary.getDictionary("module13");
				if(Integer.parseInt(m13.get("code")) >= 1 && Integer.parseInt(m13.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m13.get("code")), Integer.parseInt(m13.get("X")), Integer.parseInt(m13.get("Y")), m13.get("turns"), "Plain", m13.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m13.get("code")) >= 61 && Integer.parseInt(m13.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m13.get("code")), Integer.parseInt(m13.get("X")), Integer.parseInt(m13.get("Y")), m13.get("turns"), "Dormitory", m13.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m13.get("code")) >= 91 && Integer.parseInt(m13.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m13.get("code")), Integer.parseInt(m13.get("X")), Integer.parseInt(m13.get("Y")), m13.get("turns"), "Sanitation", m13.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m13.get("code")) >= 111 && Integer.parseInt(m13.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m13.get("code")), Integer.parseInt(m13.get("X")), Integer.parseInt(m13.get("Y")), m13.get("turns"), "Food & Water", m13.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m13.get("code")) >= 131 && Integer.parseInt(m13.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m13.get("code")), Integer.parseInt(m13.get("X")), Integer.parseInt(m13.get("Y")), m13.get("turns"), "Gym & Relaxation", m13.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m13.get("code")) >= 141 && Integer.parseInt(m13.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m13.get("code")), Integer.parseInt(m13.get("X")), Integer.parseInt(m13.get("Y")), m13.get("turns"), "Canteen", m13.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m13.get("code")) >= 151 && Integer.parseInt(m13.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m13.get("code")), Integer.parseInt(m13.get("X")), Integer.parseInt(m13.get("Y")), m13.get("turns"), "Power", m13.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m13.get("code")) >= 161 && Integer.parseInt(m13.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m13.get("code")), Integer.parseInt(m13.get("X")), Integer.parseInt(m13.get("Y")), m13.get("turns"), "Control", m13.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m13.get("code")) >= 171 && Integer.parseInt(m13.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m13.get("code")), Integer.parseInt(m13.get("X")), Integer.parseInt(m13.get("Y")), m13.get("turns"), "Airlock", m13.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m13.get("code")) >= 181 && Integer.parseInt(m13.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m13.get("code")), Integer.parseInt(m13.get("X")), Integer.parseInt(m13.get("Y")), m13.get("turns"), "Medical", m13.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}

				Dictionary m14 = Dictionary.getDictionary("module14");
				if(Integer.parseInt(m14.get("code")) >= 1 && Integer.parseInt(m14.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m14.get("code")), Integer.parseInt(m14.get("X")), Integer.parseInt(m14.get("Y")), m14.get("turns"), "Plain", m14.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m14.get("code")) >= 61 && Integer.parseInt(m14.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m14.get("code")), Integer.parseInt(m14.get("X")), Integer.parseInt(m14.get("Y")), m14.get("turns"), "Dormitory", m14.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m14.get("code")) >= 91 && Integer.parseInt(m14.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m14.get("code")), Integer.parseInt(m14.get("X")), Integer.parseInt(m14.get("Y")), m14.get("turns"), "Sanitation", m14.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m14.get("code")) >= 111 && Integer.parseInt(m14.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m14.get("code")), Integer.parseInt(m14.get("X")), Integer.parseInt(m14.get("Y")), m14.get("turns"), "Food & Water", m14.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m14.get("code")) >= 131 && Integer.parseInt(m14.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m14.get("code")), Integer.parseInt(m14.get("X")), Integer.parseInt(m14.get("Y")), m14.get("turns"), "Gym & Relaxation", m14.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m14.get("code")) >= 141 && Integer.parseInt(m14.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m14.get("code")), Integer.parseInt(m14.get("X")), Integer.parseInt(m14.get("Y")), m14.get("turns"), "Canteen", m14.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m14.get("code")) >= 151 && Integer.parseInt(m14.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m14.get("code")), Integer.parseInt(m14.get("X")), Integer.parseInt(m14.get("Y")), m14.get("turns"), "Power", m14.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m14.get("code")) >= 161 && Integer.parseInt(m14.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m14.get("code")), Integer.parseInt(m14.get("X")), Integer.parseInt(m14.get("Y")), m14.get("turns"), "Control", m14.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m14.get("code")) >= 171 && Integer.parseInt(m14.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m14.get("code")), Integer.parseInt(m14.get("X")), Integer.parseInt(m14.get("Y")), m14.get("turns"), "Airlock", m14.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m14.get("code")) >= 181 && Integer.parseInt(m14.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m14.get("code")), Integer.parseInt(m14.get("X")), Integer.parseInt(m14.get("Y")), m14.get("turns"), "Medical", m14.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}

				Dictionary m15 = Dictionary.getDictionary("module15");
				if(Integer.parseInt(m15.get("code")) >= 1 && Integer.parseInt(m15.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m15.get("code")), Integer.parseInt(m15.get("X")), Integer.parseInt(m15.get("Y")), m15.get("turns"), "Plain", m15.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m15.get("code")) >= 61 && Integer.parseInt(m15.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m15.get("code")), Integer.parseInt(m15.get("X")), Integer.parseInt(m15.get("Y")), m15.get("turns"), "Dormitory", m15.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m15.get("code")) >= 91 && Integer.parseInt(m15.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m15.get("code")), Integer.parseInt(m15.get("X")), Integer.parseInt(m15.get("Y")), m15.get("turns"), "Sanitation", m15.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m15.get("code")) >= 111 && Integer.parseInt(m15.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m15.get("code")), Integer.parseInt(m15.get("X")), Integer.parseInt(m15.get("Y")), m15.get("turns"), "Food & Water", m15.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m15.get("code")) >= 131 && Integer.parseInt(m15.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m15.get("code")), Integer.parseInt(m15.get("X")), Integer.parseInt(m15.get("Y")), m15.get("turns"), "Gym & Relaxation", m15.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m15.get("code")) >= 141 && Integer.parseInt(m15.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m15.get("code")), Integer.parseInt(m15.get("X")), Integer.parseInt(m15.get("Y")), m15.get("turns"), "Canteen", m15.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m15.get("code")) >= 151 && Integer.parseInt(m15.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m15.get("code")), Integer.parseInt(m15.get("X")), Integer.parseInt(m15.get("Y")), m15.get("turns"), "Power", m15.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m15.get("code")) >= 161 && Integer.parseInt(m15.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m15.get("code")), Integer.parseInt(m15.get("X")), Integer.parseInt(m15.get("Y")), m15.get("turns"), "Control", m15.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m15.get("code")) >= 171 && Integer.parseInt(m15.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m15.get("code")), Integer.parseInt(m15.get("X")), Integer.parseInt(m15.get("Y")), m15.get("turns"), "Airlock", m15.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m15.get("code")) >= 181 && Integer.parseInt(m15.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m15.get("code")), Integer.parseInt(m15.get("X")), Integer.parseInt(m15.get("Y")), m15.get("turns"), "Medical", m15.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}
				
				Dictionary m16 = Dictionary.getDictionary("module16");
				if(Integer.parseInt(m16.get("code")) >= 1 && Integer.parseInt(m16.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m16.get("code")), Integer.parseInt(m16.get("X")), Integer.parseInt(m16.get("Y")), m16.get("turns"), "Plain", m16.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m16.get("code")) >= 61 && Integer.parseInt(m16.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m16.get("code")), Integer.parseInt(m16.get("X")), Integer.parseInt(m16.get("Y")), m16.get("turns"), "Dormitory", m16.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m16.get("code")) >= 91 && Integer.parseInt(m16.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m16.get("code")), Integer.parseInt(m16.get("X")), Integer.parseInt(m16.get("Y")), m16.get("turns"), "Sanitation", m16.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m16.get("code")) >= 111 && Integer.parseInt(m16.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m16.get("code")), Integer.parseInt(m16.get("X")), Integer.parseInt(m16.get("Y")), m16.get("turns"), "Food & Water", m16.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m16.get("code")) >= 131 && Integer.parseInt(m16.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m16.get("code")), Integer.parseInt(m16.get("X")), Integer.parseInt(m16.get("Y")), m16.get("turns"), "Gym & Relaxation", m16.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m16.get("code")) >= 141 && Integer.parseInt(m16.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m16.get("code")), Integer.parseInt(m16.get("X")), Integer.parseInt(m16.get("Y")), m16.get("turns"), "Canteen", m16.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m16.get("code")) >= 151 && Integer.parseInt(m16.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m16.get("code")), Integer.parseInt(m16.get("X")), Integer.parseInt(m16.get("Y")), m16.get("turns"), "Power", m16.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m16.get("code")) >= 161 && Integer.parseInt(m16.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m16.get("code")), Integer.parseInt(m16.get("X")), Integer.parseInt(m16.get("Y")), m16.get("turns"), "Control", m16.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m16.get("code")) >= 171 && Integer.parseInt(m16.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m16.get("code")), Integer.parseInt(m16.get("X")), Integer.parseInt(m16.get("Y")), m16.get("turns"), "Airlock", m16.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m16.get("code")) >= 181 && Integer.parseInt(m16.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m16.get("code")), Integer.parseInt(m16.get("X")), Integer.parseInt(m16.get("Y")), m16.get("turns"), "Medical", m16.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}

				Dictionary m17 = Dictionary.getDictionary("module17");
				if(Integer.parseInt(m17.get("code")) >= 1 && Integer.parseInt(m17.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m17.get("code")), Integer.parseInt(m17.get("X")), Integer.parseInt(m17.get("Y")), m17.get("turns"), "Plain", m17.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m17.get("code")) >= 61 && Integer.parseInt(m17.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m17.get("code")), Integer.parseInt(m17.get("X")), Integer.parseInt(m17.get("Y")), m17.get("turns"), "Dormitory", m17.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m17.get("code")) >= 91 && Integer.parseInt(m17.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m17.get("code")), Integer.parseInt(m17.get("X")), Integer.parseInt(m17.get("Y")), m17.get("turns"), "Sanitation", m17.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m17.get("code")) >= 111 && Integer.parseInt(m17.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m17.get("code")), Integer.parseInt(m17.get("X")), Integer.parseInt(m17.get("Y")), m17.get("turns"), "Food & Water", m17.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m17.get("code")) >= 131 && Integer.parseInt(m17.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m17.get("code")), Integer.parseInt(m17.get("X")), Integer.parseInt(m17.get("Y")), m17.get("turns"), "Gym & Relaxation", m17.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m17.get("code")) >= 141 && Integer.parseInt(m17.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m17.get("code")), Integer.parseInt(m17.get("X")), Integer.parseInt(m17.get("Y")), m17.get("turns"), "Canteen", m17.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m17.get("code")) >= 151 && Integer.parseInt(m17.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m17.get("code")), Integer.parseInt(m17.get("X")), Integer.parseInt(m17.get("Y")), m17.get("turns"), "Power", m17.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m17.get("code")) >= 161 && Integer.parseInt(m17.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m17.get("code")), Integer.parseInt(m17.get("X")), Integer.parseInt(m17.get("Y")), m17.get("turns"), "Control", m17.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m17.get("code")) >= 171 && Integer.parseInt(m17.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m17.get("code")), Integer.parseInt(m17.get("X")), Integer.parseInt(m17.get("Y")), m17.get("turns"), "Airlock", m17.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m17.get("code")) >= 181 && Integer.parseInt(m17.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m17.get("code")), Integer.parseInt(m17.get("X")), Integer.parseInt(m17.get("Y")), m17.get("turns"), "Medical", m17.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}

				Dictionary m18 = Dictionary.getDictionary("module18");
				if(Integer.parseInt(m18.get("code")) >= 1 && Integer.parseInt(m18.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m18.get("code")), Integer.parseInt(m18.get("X")), Integer.parseInt(m18.get("Y")), m18.get("turns"), "Plain", m18.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m18.get("code")) >= 61 && Integer.parseInt(m18.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m18.get("code")), Integer.parseInt(m18.get("X")), Integer.parseInt(m18.get("Y")), m18.get("turns"), "Dormitory", m18.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m18.get("code")) >= 91 && Integer.parseInt(m18.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m18.get("code")), Integer.parseInt(m18.get("X")), Integer.parseInt(m18.get("Y")), m18.get("turns"), "Sanitation", m18.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m18.get("code")) >= 111 && Integer.parseInt(m18.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m18.get("code")), Integer.parseInt(m18.get("X")), Integer.parseInt(m18.get("Y")), m18.get("turns"), "Food & Water", m18.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m18.get("code")) >= 131 && Integer.parseInt(m18.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m18.get("code")), Integer.parseInt(m18.get("X")), Integer.parseInt(m18.get("Y")), m18.get("turns"), "Gym & Relaxation", m18.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m18.get("code")) >= 141 && Integer.parseInt(m18.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m18.get("code")), Integer.parseInt(m18.get("X")), Integer.parseInt(m18.get("Y")), m18.get("turns"), "Canteen", m18.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m18.get("code")) >= 151 && Integer.parseInt(m18.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m18.get("code")), Integer.parseInt(m18.get("X")), Integer.parseInt(m18.get("Y")), m18.get("turns"), "Power", m18.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m18.get("code")) >= 161 && Integer.parseInt(m18.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m18.get("code")), Integer.parseInt(m18.get("X")), Integer.parseInt(m18.get("Y")), m18.get("turns"), "Control", m18.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m18.get("code")) >= 171 && Integer.parseInt(m18.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m18.get("code")), Integer.parseInt(m18.get("X")), Integer.parseInt(m18.get("Y")), m18.get("turns"), "Airlock", m18.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m18.get("code")) >= 181 && Integer.parseInt(m18.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m18.get("code")), Integer.parseInt(m18.get("X")), Integer.parseInt(m18.get("Y")), m18.get("turns"), "Medical", m18.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}

				Dictionary m19 = Dictionary.getDictionary("module19");
				if(Integer.parseInt(m19.get("code")) >= 1 && Integer.parseInt(m19.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m19.get("code")), Integer.parseInt(m19.get("X")), Integer.parseInt(m19.get("Y")), m19.get("turns"), "Plain", m19.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m19.get("code")) >= 61 && Integer.parseInt(m19.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m19.get("code")), Integer.parseInt(m19.get("X")), Integer.parseInt(m19.get("Y")), m19.get("turns"), "Dormitory", m19.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m19.get("code")) >= 91 && Integer.parseInt(m19.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m19.get("code")), Integer.parseInt(m19.get("X")), Integer.parseInt(m19.get("Y")), m19.get("turns"), "Sanitation", m19.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m19.get("code")) >= 111 && Integer.parseInt(m19.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m19.get("code")), Integer.parseInt(m19.get("X")), Integer.parseInt(m19.get("Y")), m19.get("turns"), "Food & Water", m19.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m19.get("code")) >= 131 && Integer.parseInt(m19.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m19.get("code")), Integer.parseInt(m19.get("X")), Integer.parseInt(m19.get("Y")), m19.get("turns"), "Gym & Relaxation", m19.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m19.get("code")) >= 141 && Integer.parseInt(m19.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m19.get("code")), Integer.parseInt(m19.get("X")), Integer.parseInt(m19.get("Y")), m19.get("turns"), "Canteen", m19.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m19.get("code")) >= 151 && Integer.parseInt(m19.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m19.get("code")), Integer.parseInt(m19.get("X")), Integer.parseInt(m19.get("Y")), m19.get("turns"), "Power", m19.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m19.get("code")) >= 161 && Integer.parseInt(m19.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m19.get("code")), Integer.parseInt(m19.get("X")), Integer.parseInt(m19.get("Y")), m19.get("turns"), "Control", m19.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m19.get("code")) >= 171 && Integer.parseInt(m19.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m19.get("code")), Integer.parseInt(m19.get("X")), Integer.parseInt(m19.get("Y")), m19.get("turns"), "Airlock", m19.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m19.get("code")) >= 181 && Integer.parseInt(m19.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m19.get("code")), Integer.parseInt(m19.get("X")), Integer.parseInt(m19.get("Y")), m19.get("turns"), "Medical", m19.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}

				Dictionary m20 = Dictionary.getDictionary("module20");
				if(Integer.parseInt(m20.get("code")) >= 1 && Integer.parseInt(m20.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m20.get("code")), Integer.parseInt(m20.get("X")), Integer.parseInt(m20.get("Y")), m20.get("turns"), "Plain", m20.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m20.get("code")) >= 61 && Integer.parseInt(m20.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m20.get("code")), Integer.parseInt(m20.get("X")), Integer.parseInt(m20.get("Y")), m20.get("turns"), "Dormitory", m20.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m20.get("code")) >= 91 && Integer.parseInt(m20.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m20.get("code")), Integer.parseInt(m20.get("X")), Integer.parseInt(m20.get("Y")), m20.get("turns"), "Sanitation", m20.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m20.get("code")) >= 111 && Integer.parseInt(m20.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m20.get("code")), Integer.parseInt(m20.get("X")), Integer.parseInt(m20.get("Y")), m20.get("turns"), "Food & Water", m20.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m20.get("code")) >= 131 && Integer.parseInt(m20.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m20.get("code")), Integer.parseInt(m20.get("X")), Integer.parseInt(m20.get("Y")), m20.get("turns"), "Gym & Relaxation", m20.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m20.get("code")) >= 141 && Integer.parseInt(m20.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m20.get("code")), Integer.parseInt(m20.get("X")), Integer.parseInt(m20.get("Y")), m20.get("turns"), "Canteen", m20.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m20.get("code")) >= 151 && Integer.parseInt(m20.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m20.get("code")), Integer.parseInt(m20.get("X")), Integer.parseInt(m20.get("Y")), m20.get("turns"), "Power", m20.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m20.get("code")) >= 161 && Integer.parseInt(m20.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m20.get("code")), Integer.parseInt(m20.get("X")), Integer.parseInt(m20.get("Y")), m20.get("turns"), "Control", m20.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m20.get("code")) >= 171 && Integer.parseInt(m20.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m20.get("code")), Integer.parseInt(m20.get("X")), Integer.parseInt(m20.get("Y")), m20.get("turns"), "Airlock", m20.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m20.get("code")) >= 181 && Integer.parseInt(m20.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m20.get("code")), Integer.parseInt(m20.get("X")), Integer.parseInt(m20.get("Y")), m20.get("turns"), "Medical", m20.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}

				Dictionary m21 = Dictionary.getDictionary("module21");
				if(Integer.parseInt(m21.get("code")) >= 1 && Integer.parseInt(m21.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m21.get("code")), Integer.parseInt(m21.get("X")), Integer.parseInt(m21.get("Y")), m21.get("turns"), "Plain", m21.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m21.get("code")) >= 61 && Integer.parseInt(m21.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m21.get("code")), Integer.parseInt(m21.get("X")), Integer.parseInt(m21.get("Y")), m21.get("turns"), "Dormitory", m21.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m21.get("code")) >= 91 && Integer.parseInt(m21.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m21.get("code")), Integer.parseInt(m21.get("X")), Integer.parseInt(m21.get("Y")), m21.get("turns"), "Sanitation", m21.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m21.get("code")) >= 111 && Integer.parseInt(m21.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m21.get("code")), Integer.parseInt(m21.get("X")), Integer.parseInt(m21.get("Y")), m21.get("turns"), "Food & Water", m21.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m21.get("code")) >= 131 && Integer.parseInt(m21.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m21.get("code")), Integer.parseInt(m21.get("X")), Integer.parseInt(m21.get("Y")), m21.get("turns"), "Gym & Relaxation", m21.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m21.get("code")) >= 141 && Integer.parseInt(m21.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m21.get("code")), Integer.parseInt(m21.get("X")), Integer.parseInt(m21.get("Y")), m21.get("turns"), "Canteen", m21.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m21.get("code")) >= 151 && Integer.parseInt(m21.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m21.get("code")), Integer.parseInt(m21.get("X")), Integer.parseInt(m21.get("Y")), m21.get("turns"), "Power", m21.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m21.get("code")) >= 161 && Integer.parseInt(m21.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m21.get("code")), Integer.parseInt(m21.get("X")), Integer.parseInt(m21.get("Y")), m21.get("turns"), "Control", m21.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m21.get("code")) >= 171 && Integer.parseInt(m21.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m21.get("code")), Integer.parseInt(m21.get("X")), Integer.parseInt(m21.get("Y")), m21.get("turns"), "Airlock", m21.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m21.get("code")) >= 181 && Integer.parseInt(m21.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m21.get("code")), Integer.parseInt(m21.get("X")), Integer.parseInt(m21.get("Y")), m21.get("turns"), "Medical", m21.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}

				Dictionary m22 = Dictionary.getDictionary("module22");
				if(Integer.parseInt(m22.get("code")) >= 1 && Integer.parseInt(m22.get("code")) <= 60)
				{
					Module tmp = new Module(Integer.parseInt(m22.get("code")), Integer.parseInt(m22.get("X")), Integer.parseInt(m22.get("Y")), m22.get("turns"), "Plain", m22.get("status"));
					plainList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m22.get("code")) >= 61 && Integer.parseInt(m22.get("code")) <= 90)
				{
					Module tmp = new Module(Integer.parseInt(m22.get("code")), Integer.parseInt(m22.get("X")), Integer.parseInt(m22.get("Y")), m22.get("turns"), "Dormitory", m22.get("status"));
					dormitoryList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m22.get("code")) >= 91 && Integer.parseInt(m22.get("code")) <= 110)
				{
					Module tmp = new Module(Integer.parseInt(m22.get("code")), Integer.parseInt(m22.get("X")), Integer.parseInt(m22.get("Y")), m22.get("turns"), "Sanitation", m22.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m22.get("code")) >= 111 && Integer.parseInt(m22.get("code")) <= 130)
				{
					Module tmp = new Module(Integer.parseInt(m22.get("code")), Integer.parseInt(m22.get("X")), Integer.parseInt(m22.get("Y")), m22.get("turns"), "Food & Water", m22.get("status"));
					foodList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m22.get("code")) >= 131 && Integer.parseInt(m22.get("code")) <= 140)
				{
					Module tmp = new Module(Integer.parseInt(m22.get("code")), Integer.parseInt(m22.get("X")), Integer.parseInt(m22.get("Y")), m22.get("turns"), "Gym & Relaxation", m22.get("status"));
					sanitationList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m22.get("code")) >= 141 && Integer.parseInt(m22.get("code")) <= 150)
				{
					Module tmp = new Module(Integer.parseInt(m22.get("code")), Integer.parseInt(m22.get("X")), Integer.parseInt(m22.get("Y")), m22.get("turns"), "Canteen", m22.get("status"));
					canteenList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m22.get("code")) >= 151 && Integer.parseInt(m22.get("code")) <= 160)
				{
					Module tmp = new Module(Integer.parseInt(m22.get("code")), Integer.parseInt(m22.get("X")), Integer.parseInt(m22.get("Y")), m22.get("turns"), "Power", m22.get("status"));
					powerList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m22.get("code")) >= 161 && Integer.parseInt(m22.get("code")) <= 170)
				{
					Module tmp = new Module(Integer.parseInt(m22.get("code")), Integer.parseInt(m22.get("X")), Integer.parseInt(m22.get("Y")), m22.get("turns"), "Control", m22.get("status"));
					controlList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m22.get("code")) >= 171 && Integer.parseInt(m22.get("code")) <= 180)
				{
					Module tmp = new Module(Integer.parseInt(m22.get("code")), Integer.parseInt(m22.get("X")), Integer.parseInt(m22.get("Y")), m22.get("turns"), "Airlock", m22.get("status"));
					airLockList.add(tmp);
					placeModuleOnMap(tmp);
				}
				else if(Integer.parseInt(m22.get("code")) >= 181 && Integer.parseInt(m22.get("code")) <= 190)
				{
					Module tmp = new Module(Integer.parseInt(m22.get("code")), Integer.parseInt(m22.get("X")), Integer.parseInt(m22.get("Y")), m22.get("turns"), "Medical", m22.get("status"));
					medicalList.add(tmp);
					placeModuleOnMap(tmp);
				}

				
			}
		});
		menuBar_1.addItem(mntmUpdateFromGps);
		menuBar.addItem(mntmGps_1);
		
		ScrollPanel scrollPanel_1 = new ScrollPanel();
		scrollPanel_1.setAlwaysShowScrollBars(true);
		verticalPanel.add(scrollPanel_1);
		scrollPanel_1.setSize("635px", "617px");
		
		
		grid_2.setBorderWidth(0);
		grid_2.setStyleName("mapGrid");
		scrollPanel_1.setWidget(grid_2);
		grid_2.setSize("100%", "100%");
//		verticalPanel.setCellHeight(grid_2, "50px");
//		verticalPanel.setCellWidth(grid_2, "50px");
		
		Image emptyImage = new Image("images/empty.png");
		
		for(int row=0;row<50;row++)
		{
			for(int col=0; col< 100; col++)
			{
//				grid_2.setWidget(row, col, emptyImage);
//				grid_2.getCellFormatter().setWidth(row, col, "50px");
//				grid_2.getCellFormatter().setHeight(row, col, "50px");
				grid_2.setWidget(row, col, new Image("images/empty.png"));
//				grid_2.getCellFormatter().setStyleName(row,col,"viewGridCells");
			}
		}
		
		ScrollPanel scrollPanel = new ScrollPanel();
		verticalPanel.add(scrollPanel);
		scrollPanel.setSize("638px", "116px");
		
		HorizontalPanel configPanel = new HorizontalPanel();
		scrollPanel.setWidget(configPanel);
		configPanel.setSize("100%", "100%");
		
		VerticalPanel verticalPanel_1 = new VerticalPanel();
		rootPanel.add(verticalPanel_1, 637, 0);
		verticalPanel_1.setSize("387px", "333px");
		
		final DecoratedTabBar tabBar1 = new DecoratedTabBar();
		tabBar1.addTab("All");
		tabBar1.addTab("Airlock");
		tabBar1.addTab("Canteen");
		tabBar1.addTab("Control");
		tabBar1.addTab("Dormitory");
		verticalPanel_1.add(tabBar1);
		
		final DecoratedTabBar tabBar2 = new DecoratedTabBar();
		tabBar2.addTab("Food & Water");
		tabBar2.addTab("Gym & Relaxation");
		tabBar2.addTab("Medical");
		verticalPanel_1.add(tabBar2);
		
		final DecoratedTabBar tabBar3 = new DecoratedTabBar();
		tabBar3.addTab("Plain");
		tabBar3.addTab("Power");
		tabBar3.addTab("Sanitation");
		verticalPanel_1.add(tabBar3);
		
		final ListBox listBox = new ListBox();
		verticalPanel_1.add(listBox);
		listBox.setSize("388px", "263px");
		listBox.setVisibleItemCount(5);
		
		tabBar1.addSelectionHandler(new SelectionHandler<Integer>() {
			public void onSelection(SelectionEvent<Integer> event) {
				int selTab = tabBar1.getSelectedTab();
				listBox.clear();
				tab1Selected = true;
				tab2Selected = false;
				tab3Selected = false;
				if(selTab == 0)
				{
					for(Module m : airLockList)
					{
						Module tmp = m;
						listBox.addItem("Airlock    " + Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
					for(Module m : canteenList)
					{
						Module tmp = m;
						listBox.addItem("Canteen    " + Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
					for(Module m : controlList)
					{
						Module tmp = m;
						listBox.addItem("Control    " + Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
					for(Module m : dormitoryList)
					{
						Module tmp = m;
						listBox.addItem("Dormitory    " + Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
					for(Module m : foodList)
					{
						Module tmp = m;
						listBox.addItem("Food & Water    " + Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
					for(Module m : gymList)
					{
						Module tmp = m;
						listBox.addItem("Gym & Relaxation    " + Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
					for(Module m : medicalList)
					{
						Module tmp = m;
						listBox.addItem("Medical    " + Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
					for(Module m : plainList)
					{
						Module tmp = m;
						listBox.addItem("Plain    " + Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
					for(Module m : powerList)
					{
						Module tmp = m;
						listBox.addItem("Power    " + Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
					for(Module m : sanitationList)
					{
						Module tmp = m;
						listBox.addItem("Sanitation    " + Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
				}
				else if(selTab == 1)
				{
					for(Module m : airLockList)
					{
						Module tmp = m;
						listBox.addItem(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
				}
				else if(selTab == 2)
				{
					for(Module m : canteenList)
					{
						Module tmp = m;
						listBox.addItem(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
				}
				else if(selTab == 3)
				{
					for(Module m : controlList)
					{
						Module tmp = m;
						listBox.addItem(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
				}
				else if(selTab == 4)
				{
					for(Module m : dormitoryList)
					{
						Module tmp = m;
						listBox.addItem(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
				}
			}
		});
		
		tabBar2.addSelectionHandler(new SelectionHandler<Integer>() {
			public void onSelection(SelectionEvent<Integer> event) {
				int selTab = tabBar2.getSelectedTab();
				listBox.clear();
				tab1Selected = false;
				tab2Selected = true;
				tab3Selected = false;
				if(selTab == 0)
				{
					for(Module m : foodList)
					{
						Module tmp = m;
						listBox.addItem(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
				}
				else if(selTab == 1)
				{
					for(Module m : gymList)
					{
						Module tmp = m;
						listBox.addItem(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
				}
				else if(selTab == 1)
				{
					for(Module m : medicalList)
					{
						Module tmp = m;
						listBox.addItem(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
				}
			}
		});
		
		tabBar3.addSelectionHandler(new SelectionHandler<Integer>(){
			public void onSelection(SelectionEvent<Integer> event) {
				int selTab = tabBar3.getSelectedTab();
				listBox.clear();
				tab1Selected = false;
				tab2Selected = false;
				tab3Selected = true;
				if(selTab == 0)
				{
					for(Module m : plainList)
					{
						Module tmp = m;
						listBox.addItem(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
				}
				else if(selTab == 1)
				{
					for(Module m : powerList)
					{
						Module tmp = m;
						listBox.addItem(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
				}
				else if(selTab == 2)
				{
					for(Module m : sanitationList)
					{
						Module tmp = m;
						listBox.addItem(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					}
				}
			}
		});
		
		Grid grid = new Grid(6, 2);
		grid.setStyleName("addModuleGrid");
		verticalPanel_1.add(grid);
		grid.setSize("387px", "236px");
		
		Label lblNewLabel = new Label("Module Type:");
		grid.setWidget(0, 0, lblNewLabel);
		
		
		typeDrop.addItem("Airlock");
		typeDrop.addItem("Canteen");
		typeDrop.addItem("Control");
		typeDrop.addItem("Dormitory");
		typeDrop.addItem("Food & Water");
		typeDrop.addItem("Gym & Relaxation");
		typeDrop.addItem("Medical");
		typeDrop.addItem("Plain");
		typeDrop.addItem("Power");
		typeDrop.addItem("Sanitation");
		grid.setWidget(0, 1, typeDrop);
		
		Label lblNewLabel_1 = new Label("Module Condition:");
		grid.setWidget(1, 0, lblNewLabel_1);
		
		
		condDrop.addItem("undamaged");
		condDrop.addItem("damaged");
		condDrop.addItem("uncertain");
		grid.setWidget(1, 1, condDrop);
		condDrop.setSize("135px", "26");
		
		Label lblModuleNumber = new Label("Module Number:");
		grid.setWidget(2, 0, lblModuleNumber);
		

		grid.setWidget(2, 1, numBox);
		
		Label lblTurns = new Label("Turns:");
		grid.setWidget(3, 0, lblTurns);
		

		turnBox.addItem("0");
		turnBox.addItem("1");
		turnBox.addItem("2");
		grid.setWidget(3, 1, turnBox);
		turnBox.setSize("135px", "26");
		
		Label lblLongitude = new Label("X:");
		grid.setWidget(4, 0, lblLongitude);
		
		
		grid.setWidget(4, 1, longBox);
		
		Label lblLatitude = new Label("Y:");
		grid.setWidget(5, 0, lblLatitude);
		grid.getCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_TOP);
		grid.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
		grid.getCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP);
		grid.getCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_TOP);
		grid.getCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_TOP);
		grid.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_CENTER);
		grid.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
		grid.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
		grid.getCellFormatter().setVerticalAlignment(4, 0, HasVerticalAlignment.ALIGN_TOP);
		grid.getCellFormatter().setHorizontalAlignment(4, 0, HasHorizontalAlignment.ALIGN_CENTER);
		grid.getCellFormatter().setHorizontalAlignment(4, 1, HasHorizontalAlignment.ALIGN_LEFT);
		grid.getCellFormatter().setVerticalAlignment(4, 1, HasVerticalAlignment.ALIGN_TOP);
		grid.getCellFormatter().setHorizontalAlignment(5, 0, HasHorizontalAlignment.ALIGN_CENTER);
		grid.getCellFormatter().setVerticalAlignment(5, 0, HasVerticalAlignment.ALIGN_TOP);
		grid.getCellFormatter().setVerticalAlignment(5, 1, HasVerticalAlignment.ALIGN_TOP);
		grid.getCellFormatter().setVerticalAlignment(2, 1, HasVerticalAlignment.ALIGN_TOP);
		grid.getCellFormatter().setHorizontalAlignment(3, 0, HasHorizontalAlignment.ALIGN_CENTER);
		grid.getCellFormatter().setVerticalAlignment(3, 0, HasVerticalAlignment.ALIGN_TOP);
		
		
		grid.setWidget(5, 1, latBox);
		
		Grid grid_1 = new Grid(1, 6);
		verticalPanel_1.add(grid_1);
		
		Label label = new Label("");
		grid_1.setWidget(0, 0, label);
		grid_1.getCellFormatter().setWidth(0, 0, "25");
		
		
		btnAddModule.setText("Add Module");
		grid_1.setWidget(0, 1, btnAddModule);
		
		Label label_1 = new Label("");
		grid_1.setWidget(0, 2, label_1);
		grid_1.getCellFormatter().setWidth(0, 2, "25");

		
		btnUpdateModule.setEnabled(false);
		grid_1.setWidget(0, 3, btnUpdateModule);
		
		Label lblNewLabel_2 = new Label("");
		grid_1.setWidget(0, 4, lblNewLabel_2);
		grid_1.getCellFormatter().setWidth(0, 4, "25");
		
		
		grid_1.setWidget(0, 5, btnDeleteModule);
		
		final TextArea messageBox = new TextArea();
		messageBox.setTextAlignment(TextBoxBase.ALIGN_LEFT);
		rootPanel.add(messageBox, 637, 634);
		messageBox.setSize("378px", "124px");
		btnAddModule.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				int sel = typeDrop.getSelectedIndex();
				String typ = typeDrop.getValue(sel);
				if(typ.equals("Airlock"))
				{
					int sel2 = condDrop.getSelectedIndex();
					int sel3 = turnBox.getSelectedIndex();
					Module tmp = new Module(numBox.getValue(), longBox.getValue(), latBox.getValue(), turnBox.getValue(sel3), "Airlock", condDrop.getValue(sel2));
					airLockList.add(tmp);
					messageBox.setText(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					numBox.setText("");
					latBox.setText("");
					longBox.setText("");
					placeModuleOnMap(tmp);
				}
				else if(typ.equals("Canteen"))
				{
					int sel2 = condDrop.getSelectedIndex();
					int sel3 = turnBox.getSelectedIndex();
					Module tmp = new Module(numBox.getValue(), longBox.getValue(), latBox.getValue(), turnBox.getValue(sel3), "Canteen", condDrop.getValue(sel2));
					canteenList.add(tmp);
					messageBox.setText(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					numBox.setText("");
					latBox.setText("");
					longBox.setText("");
					placeModuleOnMap(tmp);
				}
				else if(typ.equals("Control"))
				{
					int sel2 = condDrop.getSelectedIndex();
					int sel3 = turnBox.getSelectedIndex();
					Module tmp = new Module(numBox.getValue(), longBox.getValue(), latBox.getValue(), turnBox.getValue(sel3), "Control", condDrop.getValue(sel2));
					controlList.add(tmp);
					messageBox.setText(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					numBox.setText("");
					latBox.setText("");
					longBox.setText("");
					placeModuleOnMap(tmp);
				}
				else if(typ.equals("Dormitory"))
				{
					int sel2 = condDrop.getSelectedIndex();
					int sel3 = turnBox.getSelectedIndex();
					Module tmp = new Module(numBox.getValue(), longBox.getValue(), latBox.getValue(), turnBox.getValue(sel3), "Dormitory", condDrop.getValue(sel2));
					dormitoryList.add(tmp);
					messageBox.setText(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					numBox.setText("");
					latBox.setText("");
					longBox.setText("");
					placeModuleOnMap(tmp);
				}
				else if(typ.equals("Food & Water"))
				{
					int sel2 = condDrop.getSelectedIndex();
					int sel3 = turnBox.getSelectedIndex();
					Module tmp = new Module(numBox.getValue(), longBox.getValue(), latBox.getValue(), turnBox.getValue(sel3), "Food & Water", condDrop.getValue(sel2));
					foodList.add(tmp);
					messageBox.setText(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					numBox.setText("");
					latBox.setText("");
					longBox.setText("");
					placeModuleOnMap(tmp);
				}
				else if(typ.equals("Gym & Relaxation"))
				{
					int sel2 = condDrop.getSelectedIndex();
					int sel3 = turnBox.getSelectedIndex();
					Module tmp = new Module(numBox.getValue(), longBox.getValue(), latBox.getValue(), turnBox.getValue(sel3), "Gym & Relaxation", condDrop.getValue(sel2));
					gymList.add(tmp);
					messageBox.setText(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					numBox.setText("");
					latBox.setText("");
					longBox.setText("");
					placeModuleOnMap(tmp);
				}
				else if(typ.equals("Medical"))
				{
					int sel2 = condDrop.getSelectedIndex();
					int sel3 = turnBox.getSelectedIndex();
					Module tmp = new Module(numBox.getValue(), longBox.getValue(), latBox.getValue(), turnBox.getValue(sel3), "Medical", condDrop.getValue(sel2));
					medicalList.add(tmp);
					messageBox.setText(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					numBox.setText("");
					latBox.setText("");
					longBox.setText("");
					placeModuleOnMap(tmp);
				}
				else if(typ.equals("Plain"))
				{
					int sel2 = condDrop.getSelectedIndex();
					int sel3 = turnBox.getSelectedIndex();
					Module tmp = new Module(numBox.getValue(), longBox.getValue(), latBox.getValue(), turnBox.getValue(sel3), "Plain", condDrop.getValue(sel2));
					plainList.add(tmp);
					messageBox.setText(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					numBox.setText("");
					latBox.setText("");
					longBox.setText("");
					placeModuleOnMap(tmp);
				}
				else if(typ.equals("Power"))
				{
					int sel2 = condDrop.getSelectedIndex();
					int sel3 = turnBox.getSelectedIndex();
					Module tmp = new Module(numBox.getValue(), longBox.getValue(), latBox.getValue(), turnBox.getValue(sel3), "Power", condDrop.getValue(sel2));
					powerList.add(tmp);
					messageBox.setText(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					numBox.setText("");
					latBox.setText("");
					longBox.setText("");
					placeModuleOnMap(tmp);
				}
				else if(typ.equals("Sanitation"))
				{
					int sel2 = condDrop.getSelectedIndex();
					int sel3 = turnBox.getSelectedIndex();
					Module tmp = new Module(numBox.getValue(), longBox.getValue(), latBox.getValue(), turnBox.getValue(sel3), "Sanitation", condDrop.getValue(sel2));
					sanitationList.add(tmp);
					messageBox.setText(Integer.toString(tmp.getNum()) + "         " + tmp.getCond() + "        X: " + Double.toString(tmp.getX()) + "  Y: " + Double.toString(tmp.getY()) + "  Turns: " + tmp.getOrient());
					numBox.setText("");
					latBox.setText("");
					longBox.setText("");
					placeModuleOnMap(tmp);
				}
				checkForMin();
				saveToLocalStorage();
			}
		});

		btnDeleteModule.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				int sel = listBox.getSelectedIndex();
				int tab=0;
				String tmp = listBox.getValue(sel);
				if(tab1Selected)
				{
					tab = tabBar1.getSelectedTab();
				}
				else if(tab2Selected)
				{
					tab = tabBar2.getSelectedTab();
				}
				else if(tab3Selected)
				{
					tab = tabBar3.getSelectedTab();
				}
				findItemToDelete(tab, tmp);
			}
		});
		
		listBox.addChangeHandler(new ChangeHandler() {
			public void onChange(ChangeEvent event) {
				int sel = listBox.getSelectedIndex();
				int tab=0;
				String tmp = listBox.getValue(sel);
				if(tab1Selected)
				{
					tab = tabBar1.getSelectedTab();
				}
				else if(tab2Selected)
				{
					tab = tabBar2.getSelectedTab();
				}
				else if(tab3Selected)
				{
					tab = tabBar3.getSelectedTab();
				}
				findItemToUpdate(tab, tmp);
			}
		});
		
		btnUpdateModule.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				placeBlankModuleOnMap(selMod);
				selMod.setNum(numBox.getValue());
				selMod.setX(longBox.getValue());
				selMod.setY(latBox.getValue());
				int t = condDrop.getSelectedIndex();
				selMod.setCond(condDrop.getValue(t));
				int x = typeDrop.getSelectedIndex();
				selMod.setType(typeDrop.getValue(x));
				int y = turnBox.getSelectedIndex();
				selMod.setOrient(turnBox.getValue(y));
				
				typeDrop.setSelectedIndex(0);
				condDrop.setSelectedIndex(0);
				turnBox.setSelectedIndex(0);
				numBox.setText("");
				longBox.setText("");
				latBox.setText("");
				btnUpdateModule.setEnabled(false);
				btnAddModule.setEnabled(true);
				String ta = messageBox.getText();
				placeModuleOnMap(selMod);
				messageBox.setText("Updated Module Successfully\n" + ta);
			}
		});
	}
	
	public void placeBlankModuleOnMap(Module m)
	{
		int mapRow = 50-m.getY();
		int mapCol = m.getX()-1;
		grid_2.setWidget(mapRow, mapCol, new Image("images/empty.png"));
	}
	
	public void placeModuleOnMap(Module m)
	{
		int mapRow = 50-m.getY();
		int mapCol = m.getX()-1;
		String type = m.getType();
		if(type.equals("Airlock"))
		{
			grid_2.setWidget(mapRow, mapCol, new Image("images/airlock.png"));
		}
		else if(type.equals("Canteen"))
		{
			grid_2.setWidget(mapRow, mapCol, new Image("images/canteen.png"));
		}
		else if(type.equals("Control"))
		{
			grid_2.setWidget(mapRow, mapCol, new Image("images/control.png"));
		}
		else if(type.equals("Dormitory"))
		{
			grid_2.setWidget(mapRow, mapCol, new Image("images/dormitory.png"));
		}
		else if(type.equals("Food & Water"))
		{
			grid_2.setWidget(mapRow, mapCol, new Image("images/food.png"));
		}
		else if(type.equals("Gym & Relaxation"))
		{
			grid_2.setWidget(mapRow, mapCol, new Image("images/gym.png"));
		}
		else if(type.equals("Medical"))
		{
			grid_2.setWidget(mapRow, mapCol, new Image("images/medical.png"));
		}
		else if(type.equals("Plain"))
		{
			grid_2.setWidget(mapRow, mapCol, new Image("images/plain.png"));
		}
		else if(type.equals("Power"))
		{
			grid_2.setWidget(mapRow, mapCol, new Image("images/power.png"));
		}
		else if(type.equals("Sanitation"))
		{
			grid_2.setWidget(mapRow, mapCol, new Image("images/sanitation.png"));
		}
	}
	
	public void findItemToUpdate(int selTab, String itemSelected)
	{
		if(tab1Selected)
		{
			if(selTab == 0)
			{
				for(Module m : airLockList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(0);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
				for(Module m : canteenList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(1);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
				for(Module m : controlList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(2);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
				for(Module m : dormitoryList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(3);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
				for(Module m : foodList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(4);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
				for(Module m : gymList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(5);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
				for(Module m : medicalList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(6);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(6);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
				for(Module m : plainList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(7);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
				for(Module m : powerList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(8);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
				for(Module m : sanitationList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(9);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
			}
			else if(selTab == 1)
			{	
				for(Module m : airLockList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(0);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
			}
			else if(selTab == 2)
			{	
				for(Module m : canteenList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(1);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
			}
			else if(selTab == 3)
			{
				for(Module m : controlList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(2);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
			}
			else if(selTab == 4)
			{	
				for(Module m : dormitoryList)
				{
					
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(3);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
			}
		}
		else if(tab2Selected)
		{
			if(selTab == 0)
			{	
				for(Module m : foodList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(4);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
			}
			else if(selTab == 1)
			{
				for(Module m : gymList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(5);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
			}
			else if(selTab == 2)
			{
				for(Module m : medicalList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(6);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
			}
		}
		else if(tab3Selected)
		{
			if(selTab == 0)
			{	
				for(Module m : plainList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(7);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
			}
			else if(selTab == 1)
			{
				for(Module m : powerList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(8);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
			}
			else if(selTab == 2)
			{
				for(Module m : sanitationList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						selMod = m;
						btnUpdateModule.setEnabled(true);
						btnAddModule.setEnabled(false);
						typeDrop.setSelectedIndex(9);
						if(m.getCond().equals("undamaged"))
						{
							condDrop.setSelectedIndex(0);
						}
						else if(m.getCond().equals("damaged"))
						{
							condDrop.setSelectedIndex(1);
						}
						else if(m.getCond().equals("uncertain"))
						{
							condDrop.setSelectedIndex(2);
						}
						numBox.setText(Integer.toString(m.getNum()));
						if(m.getOrient().equals("0"))
						{
							turnBox.setSelectedIndex(0);
						}
						else if(m.getOrient().equals("1"))
						{
							turnBox.setSelectedIndex(1);
						}
						else if(m.getOrient().equals("2"))
						{
							turnBox.setSelectedIndex(2);
						}
						longBox.setText(Integer.toString(m.getX()));
						latBox.setText(Integer.toString(m.getY()));
					}
					break;
				}
			}
		}
	}
	
	public void checkForMin()
	{
		boolean minMet = false;
		if(!dormitoryList.isEmpty())
		{
			if(!sanitationList.isEmpty())
			{
				if(!canteenList.isEmpty())
				{
					if(!foodList.isEmpty())
					{
						if(!controlList.isEmpty())
						{
							if(!powerList.isEmpty())
							{
								if(!airLockList.isEmpty())
								{
									if(plainList.size() > 2)
									{
										minMet = true;
									}
								}
							}
						}
					}
				}
			}
		}
		if(minMet)
		{
			ConfigGenerator newGen = new ConfigGenerator(allModules);
			config1 = newGen.Generate();
			/*
			Module plainMod = new Module(40, 50, 26, "0", "Plain", "undamaged");
			config1.add(plainMod);
			Module plainMod1 = new Module(41, 50, 25, "0", "Plain", "undamaged");
			config1.add(plainMod1);
			Module plainMod2 = new Module(42, 51, 26, "0", "Plain", "undamaged");
			config1.add(plainMod2);
			Module airMod = new Module(171, 50, 24, "0", "Airlock", "undamaged");
			config1.add(airMod);
			Module powerMod = new Module(151, 49, 25, "0", "Power", "undamaged");
			config1.add(powerMod);
			Module controlMod = new Module(161, 49, 26, "0", "Control", "undamaged");
			config1.add(controlMod);
			Module foodMod = new Module(111, 50, 27, "0", "Food & Water", "undamaged");
			config1.add(foodMod);
			Module canMod = new Module(141, 51, 27, "0", "Canteen", "undamaged");
			config1.add(canMod);
			Module sanMod = new Module(91, 51, 25, "0", "Sanitation", "undamaged");
			config1.add(sanMod);
			Module dormMod = new Module(61, 52, 26, "0", "Dormitory", "undamaged");
			config1.add(dormMod);
			*/
			for(Module m : config1)
			{
				placeModuleOnMap(m);
			}
		}
	}
	
	public void saveToLocalStorage()
	{
		String allModules = "[";
		for(Module m : airLockList)
		{
			allModules += "{code:" + m.getNum() + ",status:\"" + m.getCond() + "\",turns:\"" + m.getOrient() + "\",X:" + m.getX() + ",Y:" + m.getY() + "},";
		}
		for(Module m : canteenList)
		{
			allModules += "{code:" + m.getNum() + ",status:\"" + m.getCond() + "\",turns:\"" + m.getOrient() + "\",X:" + m.getX() + ",Y:" + m.getY() + "},";
		}
		for(Module m : controlList)
		{
			allModules += "{code:" + m.getNum() + ",status:\"" + m.getCond() + "\",turns:\"" + m.getOrient() + "\",X:" + m.getX() + ",Y:" + m.getY() + "},";
		}
		for(Module m : dormitoryList)
		{
			allModules += "{code:" + m.getNum() + ",status:\"" + m.getCond() + "\",turns:\"" + m.getOrient() + "\",X:" + m.getX() + ",Y:" + m.getY() + "},";
		}
		for(Module m : foodList)
		{
			allModules += "{code:" + m.getNum() + ",status:\"" + m.getCond() + "\",turns:\"" + m.getOrient() + "\",X:" + m.getX() + ",Y:" + m.getY() + "},";
		}
		for(Module m : gymList)
		{
			allModules += "{code:" + m.getNum() + ",status:\"" + m.getCond() + "\",turns:\"" + m.getOrient() + "\",X:" + m.getX() + ",Y:" + m.getY() + "},";
		}
		for(Module m : medicalList)
		{
			allModules += "{code:" + m.getNum() + ",status:\"" + m.getCond() + "\",turns:\"" + m.getOrient() + "\",X:" + m.getX() + ",Y:" + m.getY() + "},";
		}
		for(Module m : plainList)
		{
			allModules += "{code:" + m.getNum() + ",status:\"" + m.getCond() + "\",turns:\"" + m.getOrient() + "\",X:" + m.getX() + ",Y:" + m.getY() + "},";
		}
		for(Module m : powerList)
		{
			allModules += "{code:" + m.getNum() + ",status:\"" + m.getCond() + "\",turns:\"" + m.getOrient() + "\",X:" + m.getX() + ",Y:" + m.getY() + "},";
		}
		for(Module m : sanitationList)
		{
			allModules += "{code:" + m.getNum() + ",status:\"" + m.getCond() + "\",turns:\"" + m.getOrient() + "\",X:" + m.getX() + ",Y:" + m.getY() + "},";
		}
		allModules += "]";
		
		//Save to Local Storage
		Storage moduleStore = null;
		moduleStore = Storage.getLocalStorageIfSupported();
		if(moduleStore != null)
		{
			moduleStore.setItem("savedModules", allModules);
		}
	}
	
	public void saveConfigsToStorage()
	{
		Storage moduleStore = null;
		moduleStore = Storage.getLocalStorageIfSupported();
		int conNum = 0;
		for(List<Module> l : listOfConfigurationList)
		{
			for(Module m : l)
			{
				String allModules = "[";
				allModules += "{code:" + m.getNum() + ",status:\"" + m.getCond() + "\",turns:\"" + m.getOrient() + "\",X:" + m.getX() + ",Y:" + m.getY() + "},";
				allModules += "]";
				
				//Save to Local Storage
				if(moduleStore != null)
				{
					moduleStore.setItem("config" + conNum, allModules);
				}
			}
			conNum++;
		}
		if(moduleStore != null)
		{
			moduleStore.setItem("numConfig", "[" + "{num:" + Integer.toString(conNum) + "]");
		}
	}
	
	public void loadConfigsFromStorage()
	{
		Storage moduleStore = null;
		moduleStore = Storage.getLocalStorageIfSupported();
		String sConfigNumber = moduleStore.getItem("numConfig");
		
		com.google.gwt.json.client.JSONArray jA = (com.google.gwt.json.client.JSONArray)JSONParser.parseLenient(sConfigNumber);
		JSONNumber jN;
		JSONString jS;
		int numConfig;
		
		int n; //Module Number
		String t; //Turns
		int x; //X
		int y; //Y
		String s; //Status
		
		JSONObject jO = (JSONObject)jA.get(0);
		jN = (JSONNumber)jO.get("num");
		numConfig = (int)jN.doubleValue();
		
		for(int i = 0; i <= numConfig; i++)
		{
			String config = moduleStore.getItem("config" + Integer.toString(i));
			com.google.gwt.json.client.JSONArray jA1 = (com.google.gwt.json.client.JSONArray)JSONParser.parseLenient(config);
			JSONObject jO1 = (JSONObject)jA.get(i);
			jN = (JSONNumber)jO1.get("code");
			n = (int)jN.getValue();
			jS = (JSONString)jO1.get("status");
			s = jS.stringValue();
			jS = (JSONString)jO1.get("turns");
			t = jS.stringValue();
			jN = (JSONNumber)jO1.get("X");
			x = (int)jN.getValue();
			jN = (JSONNumber)jO1.get("Y");
			y = (int)jN.getValue();
			
			List<Module> configList = new ArrayList<Module>();
			
			if(n >= 1 && n <= 60)
			{
				Module tmp = new Module(n, x, y, t, "Plain", s);
				configList.add(tmp);
				placeModuleOnMap(tmp);
			}
			else if(n >= 61 && n <= 90)
			{
				Module tmp = new Module(n, x, y, t, "Dormitory", s);
				configList.add(tmp);
				placeModuleOnMap(tmp);
			}
			else if(n >= 91 && n <= 110)
			{
				Module tmp = new Module(n, x, y, t, "Sanitation", s);
				configList.add(tmp);
				placeModuleOnMap(tmp);
			}
			else if(n >= 111 && n <= 130)
			{
				Module tmp = new Module(n, x, y, t, "Food & Water", s);
				configList.add(tmp);
				placeModuleOnMap(tmp);
			}
			else if(n >= 131 && n <= 140)
			{
				Module tmp = new Module(n, x, y, t, "Gym & Relaxation", s);
				configList.add(tmp);
				placeModuleOnMap(tmp);
			}
			else if(n >= 141 && n <= 150)
			{
				Module tmp = new Module(n, x, y, t, "Canteen", s);
				configList.add(tmp);
				placeModuleOnMap(tmp);
			}
			else if(n >= 151 && n <= 160)
			{
				Module tmp = new Module(n, x, y, t, "Power", s);
				configList.add(tmp);
				placeModuleOnMap(tmp);
			}
			else if(n >= 161 && n <= 170)
			{
				Module tmp = new Module(n, x, y, t, "Control", s);
				configList.add(tmp);
				placeModuleOnMap(tmp);
			}
			else if(n >= 171 && n <= 180)
			{
				Module tmp = new Module(n, x, y, t, "Airlock", s);
				configList.add(tmp);
				placeModuleOnMap(tmp);
			}
			else if(n >= 181 && n <= 190)
			{
				Module tmp = new Module(n, x, y, t, "Medical", s);
				configList.add(tmp);
				placeModuleOnMap(tmp);
			}
			
			listOfConfigurationList.add(configList);
		}
	}
	
	@SuppressWarnings("deprecation")
	public void loadFromStorage()
	{
		Storage moduleStore = null;
		moduleStore = Storage.getLocalStorageIfSupported();
		String sAllModules = moduleStore.getItem("savedModules");
		
		com.google.gwt.json.client.JSONArray jA = (com.google.gwt.json.client.JSONArray)JSONParser.parseLenient(sAllModules);
		JSONNumber jN;
		JSONString jS;
		
		int n; //Module Number
		String t; //Turns
		int x; //X
		int y; //Y
		String s; //Status
		
		for(int i = 0; i < jA.size(); i++)
		{
			JSONObject jO = (JSONObject)jA.get(i);
			jN = (JSONNumber)jO.get("code");
			n = (int)jN.getValue();
			jS = (JSONString)jO.get("status");
			s = jS.stringValue();
			jS = (JSONString)jO.get("turns");
			t = jS.stringValue();
			jN = (JSONNumber)jO.get("X");
			x = (int)jN.getValue();
			jN = (JSONNumber)jO.get("Y");
			y = (int)jN.getValue();
			
			if(n >= 1 && n <= 60)
			{
				Module tmp = new Module(n, x, y, t, "Plain", s);
				plainList.add(tmp);
				placeModuleOnMap(tmp);
			}
			else if(n >= 61 && n <= 90)
			{
				Module tmp = new Module(n, x, y, t, "Dormitory", s);
				dormitoryList.add(tmp);
				placeModuleOnMap(tmp);
			}
			else if(n >= 91 && n <= 110)
			{
				Module tmp = new Module(n, x, y, t, "Sanitation", s);
				sanitationList.add(tmp);
				placeModuleOnMap(tmp);
			}
			else if(n >= 111 && n <= 130)
			{
				Module tmp = new Module(n, x, y, t, "Food & Water", s);
				foodList.add(tmp);
				placeModuleOnMap(tmp);
			}
			else if(n >= 131 && n <= 140)
			{
				Module tmp = new Module(n, x, y, t, "Gym & Relaxation", s);
				sanitationList.add(tmp);
				placeModuleOnMap(tmp);
			}
			else if(n >= 141 && n <= 150)
			{
				Module tmp = new Module(n, x, y, t, "Canteen", s);
				canteenList.add(tmp);
				placeModuleOnMap(tmp);
			}
			else if(n >= 151 && n <= 160)
			{
				Module tmp = new Module(n, x, y, t, "Power", s);
				powerList.add(tmp);
				placeModuleOnMap(tmp);
			}
			else if(n >= 161 && n <= 170)
			{
				Module tmp = new Module(n, x, y, t, "Control", s);
				controlList.add(tmp);
				placeModuleOnMap(tmp);
			}
			else if(n >= 171 && n <= 180)
			{
				Module tmp = new Module(n, x, y, t, "Airlock", s);
				airLockList.add(tmp);
				placeModuleOnMap(tmp);
			}
			else if(n >= 181 && n <= 190)
			{
				Module tmp = new Module(n, x, y, t, "Medical", s);
				medicalList.add(tmp);
				placeModuleOnMap(tmp);
			}
		}
	}
	
	public void findItemToDelete(int selTab, String itemSelected)
	{
//		String s = Character.toString(itemSelected.charAt(0));
		if(tab1Selected)
		{
			if(selTab == 0)
			{
				for(Module m : airLockList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						airLockList.remove(m);
					}
					break;
				}
				for(Module m : canteenList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						canteenList.remove(m);
					}
					break;
				}
				for(Module m : controlList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						controlList.remove(m);
					}
					break;
				}
				for(Module m : dormitoryList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						dormitoryList.remove(m);
					}
					break;
				}
				for(Module m : foodList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						foodList.remove(m);
					}
					break;
				}
				for(Module m : gymList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						gymList.remove(m);
					}
					break;
				}
				for(Module m : medicalList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						medicalList.remove(m);
					}
					break;
				}
				for(Module m : plainList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						plainList.remove(m);
					}
					break;
				}
				for(Module m : powerList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						powerList.remove(m);
					}
					break;
				}
				for(Module m : sanitationList)
				{
					String t = m.allModuleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						sanitationList.remove(m);
					}
					break;
				}
			}
			else if(selTab == 1)
			{	
				for(Module m : airLockList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						airLockList.remove(m);
					}
					break;
				}
			}
			else if(selTab == 2)
			{	
				for(Module m : canteenList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						canteenList.remove(m);
					}
					break;
				}
			}
			else if(selTab == 3)
			{	
				for(Module m : controlList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						controlList.remove(m);
					}
					break;
				}
			}
			else if(selTab == 4)
			{	
				for(Module m : dormitoryList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						dormitoryList.remove(m);
					}
					break;					
				}
			}
		}
		else if(tab2Selected)
		{
			if(selTab == 0)
			{
				for(Module m : foodList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						foodList.remove(m);
					}
					break;					
				}
			}
			else if(selTab == 1)
			{
				for(Module m : gymList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						gymList.remove(m);
					}
					break;					
				}
			}
			else if(selTab == 2)
			{
				for(Module m : medicalList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						medicalList.remove(m);
					}
					break;					
				}
			}
		}
		else if(tab3Selected)
		{
			if(selTab == 0)
			{
				for(Module m : plainList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						plainList.remove(m);
					}
					break;					
				}
			}
			else if(selTab == 1)
			{
				for(Module m : powerList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						powerList.remove(m);
					}
					break;					
				}
			}
			else if(selTab == 2)
			{
				for(Module m : sanitationList)
				{
					String t = m.moduleToString();
					if(t.equals(itemSelected))
					{
						placeBlankModuleOnMap(m);
						typeDrop.setSelectedIndex(0);
						condDrop.setSelectedIndex(0);
						turnBox.setSelectedIndex(0);
						numBox.setText("");
						longBox.setText("");
						latBox.setText("");
						sanitationList.remove(m);
					}
					break;					
				}
			}
		}
	}
}
